package com.ch.home.testMapper;

import com.ch.home.bean.RestDish;
import com.ch.home.bean.Restaurant;
import com.ch.home.mapper.restDishMapper.RestaurantMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.LinkedList;

/**
 * Created by CHEN on 2019/9/4.
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class testRestaurantMapper {


    @Autowired
    RestaurantMapper restaurantMapper;


//    int insertRestInfo(Restaurant restaurant);

    @Test
    public void testInsertRestInfo() {

        Restaurant restaurant = new Restaurant(null, "椰子奶糖的餐厅", "这是一家虚空餐厅，拥有顶级美食与服务", 9, "二号大街", "杭帮菜", "40040040011", null);

        System.out.println(restaurant);
        restaurantMapper.insertRestInfo(restaurant);

        System.out.println(restaurant);

    }

//    int updateRestInfo(Restaurant restaurant);

    @Test
    public void testUpdateRestInfo() {
        Restaurant restaurant = new Restaurant(1, "椰子奶糖的另外一个餐厅", "这也是一家虚空餐厅，拥有顶级美食与服务", 9, "二号大街", "杭帮菜", "40040040011", null);
        restaurantMapper.updateRestInfo(restaurant);
    }
//    int insertRestDishInfo(RestDish restDish);

    @Test
    public void testInsertRestDishInfo() {

        RestDish restDish = new RestDish(null, 2, 1, 1, null);

        restaurantMapper.insertRestDishInfo(restDish);
        System.out.println(restDish.getId( ));
    }


    //    int updateRestDishInfo(RestDish restDish);
    @Test
    public void testUpdateRestDishInfo() {
        RestDish restDish = new RestDish(3, null, null, 1, null);
        restaurantMapper.updateRestDishInfo(restDish);


    }

    //    int insertMulRestDishInfo(LinkedList<RestDish> list);
    @Test
    public void testInsertMulRestDishInfo() {
        LinkedList<RestDish> list = new LinkedList<>();

        list.add(new RestDish(null, 2, 6, 1, null));
        list.add(new RestDish(null, 2, 7, 1, null));
        list.add(new RestDish(null, 2, 9, 1, null));

        restaurantMapper.insertMulRestDishInfo(list);
    }
//    LinkedList<Restaurant> getRestaurantList(Restaurant restaurant);

    @Test
    public void testGetRestaurantList(){
        Restaurant restaurant = new Restaurant(null, null, null, null, null, "杭帮菜", null, null);

        LinkedList<Restaurant> restaurantList = restaurantMapper.getRestaurantList(restaurant);
        for (Restaurant r:restaurantList
             ) {
            System.out.println("---------------------------------" );
            System.out.println(r );
            System.out.println("---------------------------------" );

        }

    }
//    Restaurant getRestaurantById(Restaurant restaurant);

    @Test
    public void testGetRestaurantById(){

        Restaurant restaurant = new Restaurant(1, null, null, null, null, null, null, null);


        Restaurant result = restaurantMapper.getRestaurantById(restaurant);
        System.out.println(result );


    }

}
